!****************************
MODULE ElliDef
!***************************

IMPLICIT NONE
SAVE
PRIVATE
INTEGER, PUBLIC, PARAMETER :: NM=0,DR=1
INTEGER, PUBLIC, PARAMETER :: Precision=SELECTED_REAL_KIND(14,32),InternalBC=999, &
     CSR_LAPL=7,CSR_PRECOND=8 ! last two refer to where the operators are
REAL (KIND=Precision), PUBLIC, PARAMETER :: zero=0.0D0,one=1.0d0
TYPE, PUBLIC :: BC
   INTEGER :: bc_type
   REAL (KIND=Precision), POINTER, DIMENSION (:,:) :: p
END TYPE BC
TYPE,PUBLIC :: CRS
   INTEGER :: nNonZeros ! rather unhappy name. 
                        !it is in fact the number of columns of the matrix
   REAL (KIND=Precision), POINTER, DIMENSION (:) :: rValues =>NULL() 
   INTEGER,  POINTER, DIMENSION (:) :: columns=>NULL(),rowIndex=>NULL()
END TYPE CRS
TYPE, PUBLIC :: CRS_P
   TYPE (CRS), POINTER :: crsptr
END TYPE CRS_P

TYPE :: IT
   INTEGER :: lfil  ! infil of LU precond
   REAL (KIND=Precision) :: droptol ! tol used for LU precond
   REAL (KIND=Precision), DIMENSION (:), POINTER :: fpar=>NULL()
   INTEGER , DIMENSION (:), POINTER :: perm=>NULL()
   INTEGER, DIMENSION (:), POINTER :: ipar_pd=>NULL(),ipar_it=>NULL()
   TYPE (CRS) :: G
END TYPE IT


TYPE, PUBLIC :: Elli
   INTEGER :: ndim
   INTEGER :: mX(3),mthbc(6)
   REAL (KIND=Precision) :: dX(3)

   TYPE (CRS_P), POINTER,  DIMENSION (:) :: G => NULL()
   TYPE (BC), POINTER, DIMENSION (:) :: bc => NULL()
   TYPE (IT) :: it
   INTEGER (KIND=INT_PTR_KIND()), POINTER, DIMENSION (:) :: pt => NULL()
   INTEGER (KIND=INT_PTR_KIND()), POINTER, DIMENSION (:) :: ptprcond => NULL()
!   INTEGER (KIND=4), POINTER, DIMENSION (:) :: pt => NULL()
   REAL (KIND=Precision), POINTER, DIMENSION (:,:,:) :: div,p,pold,diag
   REAL (KIND=Precision), POINTER, DIMENSION (:,:,:,:) :: qe
   
END TYPE Elli

END MODULE ElliDef

   
   
